unit PlayerProfiles;

interface

uses
  Database, SingleProfile,
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, ExtCtrls, ComCtrls, Gauges, DB, Grids,
  Mask, Menus, DBTables, DBGrids, PortalGrid;

type
  TFormProfiles = class(TForm)
    DialogSave: TSaveDialog;
    TimerExport: TTimer;
    PanelMain: TPanel;
    BtnHelp: TBitBtn;
    BtnExport: TBitBtn;
    Label5: TLabel;
    BtnDelete: TBitBtn;
    BtnClose: TBitBtn;
    MainMenu: TMainMenu;
    MenuHelp: TMenuItem;
    PanelHint: TPanel;
    Status: TLabel;
    BtnAdd: TBitBtn;
    BtnEdit: TBitBtn;
    PanelStatus: TPanel;
    Bevel1: TBevel;
    Bevel2: TBevel;
    Gauge: TGauge;
    BtnOK: TBitBtn;
    LabelStatus: TStaticText;
    DSPlayers: TDataSource;
    GridProfiles: TPortalGrid;
    procedure BtnHelpClick(Sender: TObject);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure BtnCloseClick(Sender: TObject);
    procedure BtnAddClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure BtnDeleteClick(Sender: TObject);
    procedure GridProfilesKeyPress(Sender: TObject; var Key: Char);
    procedure BtnExportClick(Sender: TObject);
    procedure TimerExportTimer(Sender: TObject);
    procedure BtnOKClick(Sender: TObject);
  private
    { Private declarations }
    procedure ClearTable(table: TDataset);
    procedure DoExport;
  public
    { Public declarations }
    silently: boolean;
  end;

var
  FormProfiles: TFormProfiles;
  TKPFile: TextFile;
  masterindex: string;

implementation
uses
   DBClient;

{$R *.DFM}

procedure TFormProfiles.BtnHelpClick(Sender: TObject);
begin
  Datawell.Help('player_profiles');
end;

procedure TFormProfiles.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  Status.caption:=' '+(sender as TControl).hint;
end;

procedure TFormProfiles.BtnAddClick(Sender: TObject);
var form: TFormProfile;
begin
  if (Datawell.TableProfiles.fieldbyname('Master').asinteger < 1) and
    (TBitBtn(sender).tag = 2) then begin
    messagedlg('There is no profile to edit.  Please add one first',
      mtinformation,[mbok],0);
    exit;
  end;
  if TBitBtn(sender).tag = 2 then begin
    if (Datawell.TableProfiles.fieldbyname('Player').asstring = 'Quick') and
      (Datawell.TableProfiles.fieldbyname('Mud').asstring = 'Connect') then begin
      messagedlg('You cannot edit the quick connect profile',
        mtinformation,[mbok],0);
      exit;
    end;
  end;
  form:=TFormProfile.create(self);
  if TBitBtn(sender).tag = 1 then begin
    form.EditTrigger.text:='elcome';
    form.MemoScript.lines.add('PLAYER');
    form.MemoScript.lines.add('PASSWORD');
  end     
  else begin
    with Datawell.TableProfiles do begin
      form.EditPlayer.text:=fieldbyname('Player').asstring;
      form.EditMUD.text:=fieldbyname('MUD').asstring;
      form.EditPassword.text:=fieldbyname('FPassword').asstring;
      form.EditPassword2.text:=fieldbyname('Password2').asstring;
      form.EditMUDHost.text:=fieldbyname('Host').asstring;
      form.EditMUDPort.text:=fieldbyname('Port').asstring;
      form.EditTrigger.text:=fieldbyname('FTrigger').asstring;
      form.EditMUDWebsite.Text:=fieldbyname('URL').asstring;
      form.CheckCR.checked:=fieldbyname('CR').asboolean;
      form.MemoScript.lines.assign(fieldbyname('Script'));
    end;
    form.BtnNew.hide;
    form.BtnImport.left:=8;
    form.BtnImport.caption:='Overwrite with &Import';
    form.BtnSave.show;
  end;
  form.showmodal;
  form.free;
  BtnClose.setfocus;
end;

procedure TFormProfiles.BtnCloseClick(Sender: TObject);
begin
  close;
end;

procedure TFormProfiles.FormCreate(Sender: TObject);
begin
  silently:=false;
  PanelStatus.left:=78;
  PanelStatus.top:=62;
{  with GridProfiles.selected do begin
    clear;
    add('Player' + #9 + '25' + #9 + 'Player');
    add('Mud' + #9 + '25' + #9 + 'MUD');
    add('Host' + #9 + '17' + #9 + 'Host');
    add('Port' + #9 + '6' + #9 + 'Port');
  end;
  GridProfiles.applyselected; }
  GridProfiles.refresh;
end;

procedure TFormProfiles.BtnDeleteClick(Sender: TObject);
begin
  if Datawell.TableProfiles.fieldbyname('Master').asinteger < 1 then begin
    messagedlg('There is no profile to delete',mtinformation,[mbok],0);
    GridProfiles.setfocus;
    exit;
  end;
  if messagedlg('Delete profile: '+
    Datawell.TableProfiles.FieldByName('Player').asstring+' - '+
    Datawell.TableProfiles.FieldByName('Mud').asstring+'?  This cannot be undone',
    mtconfirmation,[mbyes,mbcancel],0) = mrcancel then begin
    GridProfiles.setfocus;
    exit;
  end;
  with Datawell do begin
    SetupTables(inttostr(TableProfiles.fieldbyname('Master').asinteger));
    ClearTable(TableOptions);
    ClearTable(TableOptions2);
    ClearTable(TableOptions3);
    ClearTable(TableOptions4);
    ClearTable(TableGroups);
    ClearTable(TableRetain);
    ClearTable(TableReverse);
    ClearTable(TableActions);
    ClearTable(TableAliases);
    ClearTable(TableMacros);
    ClearTable(TableMenu);
    ClearTable(TableChat);
    ClearTable(TableChathist);
    ClearTable(TableChatlines);
    ClearTable(TableEvents);
    ClearTable(TableNicknames);
    ClearTable(TableSEvents);
    ClearTable(TableTell);
    ClearTable(TableTellhist);
    ClearTable(TableTells);
    ClearTable(TableTicker);
    ClearTable(TableTools);
    ClearTable(TableVariables);
    TableProfiles.delete;
  end;
end;

procedure TFormProfiles.ClearTable(table: TDataset);
begin
  table.first;
  while not table.EOF do table.delete;
end;

procedure TFormProfiles.GridProfilesKeyPress(Sender: TObject;
  var Key: Char);
begin
  if key = #13 then begin
    key:=#0;
    BtnClose.click;
  end;
end;

procedure TFormProfiles.BtnExportClick(Sender: TObject);
begin
  if (Datawell.TableProfiles.fieldbyname('Master').asinteger < 1) and (not silently) then begin
    messagedlg('There is no profile configuration to export',mtinformation,[mbok],0);
    GridProfiles.setfocus;
    exit;
  end;
  DialogSave.initialdir:=Datawell.GetDir(1);
  DialogSave.filename:=Datawell.TableProfiles.fieldbyname('Player').asstring+' - '+
    Datawell.TableProfiles.fieldbyname('MUD').asstring;
  if not DialogSave.execute then abort;
  Datawell.SetDir(1,DialogSave.filename);
  LabelStatus.caption:='Exporting Configuration...';
  LabelStatus.font.color:=clmaroon;
  Gauge.progress:=0;
  BtnOK.enabled:=false;
  masterindex:=inttostr(Datawell.TableProfiles.fieldbyname('Master').asinteger);
  if not silently then begin
    PanelStatus.show;
    PanelStatus.refresh;
    Datawell.SetupTables(masterindex);
    TimerExport.enabled:=true;
  end
  else DoExport;
  PanelMain.enabled:=false;
end;

procedure TFormProfiles.TimerExportTimer(Sender: TObject);
begin
  TimerExport.enabled:=false;
  DoExport;
end;

procedure TFormProfiles.DoExport;
var
  adds, coms: TStringList;
  i: integer;
  work: string;
begin
  work:='FALSE';
  adds:=TStringList.create;
  coms:=TStringList.create;
//Begin adding
  adds.add('DO NOT EDIT THIS FILE!');
  adds.add(Datawell.version2);
  adds.add('20000911'); //defunct from time
  adds.add('2259'); //defunct from time
  adds.add('--------ACTIONS');
  with Datawell.TableActions do begin
    first;
    while not EOF do begin
      //Character|Action
      adds.add(fieldbyname('Character').asstring);
      adds.add(fieldbyname('Action').asstring);
      next;
    end
  end;
  adds.add('--------ALIASES');
  with Datawell.TableAliases do begin
    first;
    while not EOF do begin
      //Alias|Script
      adds.add(fieldbyname('Alias').asstring);
      coms.clear;
      coms.assign(fieldbyname('Script'));
      for i:=0 to coms.count-1 do adds.add(coms[i]);
      adds.add('<ENDSCRIPT>---');
      next;
    end
  end;
  adds.add('--------ACOMMANDS');
  adds.add('--------CHATLINES');
  with Datawell.TableChatlines do begin
    first;
    while not EOF do begin
      //Line|Command|Mask|FGColor|BGColor
      adds.add(fieldbyname('Line').asstring);
      adds.add(fieldbyname('Command').asstring);
      adds.add(fieldbyname('Mask').asstring);
      adds.add(inttostr(fieldbyname('FGColor').asinteger));
      adds.add(inttostr(fieldbyname('BGColor').asinteger));
      next;
    end
  end;
  adds.add('--------EVENTS');
  with Datawell.TableEvents do begin
    first;
    while not EOF do begin
      //Group|Event|Action|Sound|Soundfile|Fcolor|BColor|CaseSensitive|Terminal|Order|Filtered|Retain|Script
      adds.add(fieldbyname('FGroup').asstring);
      adds.add(fieldbyname('FEvent').asstring);
      adds.add(fieldbyname('FAction').asstring);
      adds.add(fieldbyname('Sound').asstring);
      adds.add(fieldbyname('Soundfile').asstring);
      adds.add(inttostr(fieldbyname('FColor').asinteger));
      adds.add(inttostr(fieldbyname('BColor').asinteger));
      work:='FALSE'; if fieldbyname('CaseSensitive').asboolean then work:='TRUE';
        adds.add(work);
      work:='FALSE'; if fieldbyname('Terminal').asboolean then work:='TRUE';
        adds.add(work);
      adds.add(inttostr(fieldbyname('FOrder').asinteger));
      work:='FALSE'; if fieldbyname('Filtered').asboolean then work:='TRUE';
        adds.add(work);
      work:='FALSE'; if fieldbyname('FRetain').asboolean then work:='TRUE';
        adds.add(work);
      coms.clear;
      coms.assign(fieldbyname('Script'));
      for i:=0 to coms.count-1 do adds.add(coms[i]);
      adds.add('<ENDSCRIPT>---');
      next;
    end
  end;
  adds.add('--------ECOMMANDS');
  adds.add('--------FILTERS'); //defunct
  adds.add('--------GROUPS');
  with Datawell.TableGroups do begin
    first;
    while not EOF do begin
      //Group|FGColor|BGColor
      adds.add(fieldbyname('FGroup').asstring);
      adds.add(inttostr(fieldbyname('FGColor').asinteger));
      adds.add(inttostr(fieldbyname('BGColor').asinteger));
      next;
    end
  end;
  adds.add('--------MACROS');
  with Datawell.TableMacros do begin
    first;
    while not EOF do begin
      //Macro|Script
      adds.add(fieldbyname('Macro').asstring);
      adds.add(fieldbyname('FOrder').asstring);
      coms.clear;
      coms.assign(fieldbyname('Script'));
      for i:=0 to coms.count-1 do adds.add(coms[i]);
      adds.add('<ENDSCRIPT>---');
      next;
    end
  end;
  adds.add('--------MCOMMANDS');
  adds.add('--------MENUS');
  with Datawell.TableMenu do begin
    first;
    while not EOF do begin
      //Index|Item|Hotkey
      adds.add(inttostr(fieldbyname('Index').asinteger));
      adds.add(fieldbyname('Item').asstring);
      adds.add(fieldbyname('Hotkey').asstring);
      next;
    end
  end;
  adds.add('--------NICKNAMES');
  with Datawell.TableNicknames do begin
    first;
    while not EOF do begin
      //Group|Nickname|Replacement
      adds.add(fieldbyname('Nickname').asstring);
      adds.add(fieldbyname('Replacement').asstring);
      next;
    end
  end;
  adds.add('--------RETAIN');
  with Datawell.TableRetain do begin
    first;
    while not EOF do begin
      //Retain|AddSpace|KeepSelected
      adds.add(fieldbyname('FRetain').asstring);
      work:='FALSE'; if fieldbyname('AddSpace').asboolean then work:='TRUE';
        adds.add(work);
      work:='FALSE'; if fieldbyname('KeepSelected').asboolean then work:='TRUE';
        adds.add(work);
      next;
    end
  end;
  adds.add('--------REVERSE');
  with Datawell.TableReverse do begin
    first;
    while not EOF do begin
      //Command|Reverse
      adds.add(fieldbyname('Command').asstring);
      adds.add(fieldbyname('Reverse').asstring);
      next;
    end
  end;
  adds.add('--------SCHEDULE'); //defunct
  adds.add('--------SEVENTS');
  with Datawell.TableSEvents do begin
    first;
    while not EOF do begin
      //Group|Kind|Action|Sound
      adds.add(fieldbyname('FGroup').asstring);
      adds.add(inttostr(fieldbyname('Kind').asinteger));
      adds.add(fieldbyname('FAction').asstring);
      adds.add(fieldbyname('Sound').asstring);
      next;
    end
  end;
  adds.add('--------TOOLS');
  with Datawell.TableTools do begin
    first;
    while not EOF do begin
      //Tool|Filename
      adds.add(fieldbyname('Tool').asstring);
      adds.add(fieldbyname('Filename').asstring);
      next;
    end
  end;
  adds.add('--------TELLS');
  with Datawell.TableTells do begin
    first;
    while not EOF do begin
      //From|FGColor|BGColor
      adds.add(fieldbyname('From').asstring);
      adds.add(inttostr(fieldbyname('FGColor').asinteger));
      adds.add(inttostr(fieldbyname('BGColor').asinteger));
      next;
    end
  end;
  adds.add('--------TICKER');
  with Datawell.TableTicker do begin
    first;
    while not EOF do begin
      //Tick|Action|Alias
      adds.add(inttostr(fieldbyname('Tick').asinteger));
      adds.add(fieldbyname('Action').asstring);
      next;
    end
  end;
  adds.add('--------VARIABLES');
  with Datawell.TableVariables do begin
    first;
    while not EOF do begin
      //Variable|Value|FColor|BColor|Initialize
      adds.add(fieldbyname('FVariable').asstring);
      adds.add(fieldbyname('FValue').asstring);
      adds.add(inttostr(fieldbyname('FColor').asinteger));
      adds.add(inttostr(fieldbyname('BColor').asinteger));
      adds.add(fieldbyname('Initialize').asstring);
      next;
    end
  end;
  adds.add('--------OPTIONS');
  with Datawell.TableOptions do begin
    adds.add(fieldbyname('FGroup').asstring);
    adds.add(fieldbyname('DirFiles').asstring);
    adds.add(fieldbyname('DirSounds').asstring);
    work:='FALSE'; if fieldbyname('Menu').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('FEscape').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('Tab').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('ShowHP').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('ShowHP2').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(fieldbyname('Toolbar').asstring);
    adds.add(fieldbyname('FToolbar').asstring);
    adds.add(inttostr(fieldbyname('ScrollPosition').asinteger));
    work:='FALSE'; if fieldbyname('Pageup').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('FeedScrollback').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('ScrollbackLabels').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('AutotypeSave').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('EventsOnFilter').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('Autocopy').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('ClearSending').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('Scroll').asinteger));
    adds.add(inttostr(fieldbyname('History').asinteger));
    adds.add(inttostr(fieldbyname('Chars').asinteger));
    adds.add(inttostr(fieldbyname('Special').asinteger));
    adds.add(inttostr(fieldbyname('SpecialDuration').asinteger));
    adds.add(inttostr(fieldbyname('Color21').asinteger));
    adds.add(inttostr(fieldbyname('Color22').asinteger));
    adds.add(inttostr(fieldbyname('Color23').asinteger));
    adds.add(fieldbyname('Beep').asstring);
    adds.add(fieldbyname('LoginMacro').asstring);
    adds.add(fieldbyname('LinkdeadMacro').asstring);
    adds.add(fieldbyname('Activator').asstring);
    work:='FALSE'; if fieldbyname('Animate').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('Sounds').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('EventSounds').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('Typed').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('FColorTyped').asinteger));
    adds.add(inttostr(fieldbyname('BColorTyped').asinteger));
    work:='FALSE'; if fieldbyname('Autotyper').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('FColorAutotyper').asinteger));
    adds.add(inttostr(fieldbyname('BColorAutotyper').asinteger));
    work:='FALSE'; if fieldbyname('Aliases').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('FColorAliases').asinteger));
    adds.add(inttostr(fieldbyname('BColorAliases').asinteger));
    work:='FALSE'; if fieldbyname('MAcros').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('FColorMacros').asinteger));
    adds.add(inttostr(fieldbyname('BColorMacros').asinteger));
    work:='FALSE'; if fieldbyname('Events').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('FColorEvents').asinteger));
    adds.add(inttostr(fieldbyname('BColorEvents').asinteger));
    work:='FALSE'; if fieldbyname('Pasted').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('FColorPasted').asinteger));
    adds.add(inttostr(fieldbyname('BColorPasted').asinteger));
    adds.add(inttostr(fieldbyname('HP').asinteger));
    adds.add(inttostr(fieldbyname('SP').asinteger));
    adds.add(inttostr(fieldbyname('GP1').asinteger));
    adds.add(inttostr(fieldbyname('GP2').asinteger));
    adds.add(inttostr(fieldbyname('Enemy').asinteger));
    adds.add(inttostr(fieldbyname('HP2').asinteger));
    adds.add(inttostr(fieldbyname('SP2').asinteger));
    adds.add(inttostr(fieldbyname('GP12').asinteger));
    adds.add(inttostr(fieldbyname('GP22').asinteger));
    adds.add(inttostr(fieldbyname('Enemy2').asinteger));
    adds.add(inttostr(fieldbyname('Top').asinteger));
    adds.add(inttostr(fieldbyname('FLeft').asinteger));
    adds.add(inttostr(fieldbyname('Height').asinteger));
    adds.add(inttostr(fieldbyname('Width').asinteger));
    adds.add(fieldbyname('FontName').asstring);
    adds.add(inttostr(fieldbyname('FontStyle').asinteger));
    adds.add(inttostr(fieldbyname('FontSize').asinteger));
    work:='FALSE'; if fieldbyname('ToolbarShowing').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('HelpbarShowing').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('StatusTop').asinteger));
    adds.add(inttostr(fieldbyname('StatusLeft').asinteger));
    work:='FALSE'; if fieldbyname('StatusShowing').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('StatusStayOnTop').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('TellTop').asinteger));
    adds.add(inttostr(fieldbyname('TellLeft').asinteger));
    adds.add(inttostr(fieldbyname('TellHeight').asinteger));
    adds.add(inttostr(fieldbyname('TellWidth').asinteger));
    work:='FALSE'; if fieldbyname('TellStayOnTop').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('TellShowing').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('TellExpanded').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('EditorTop').asinteger));
    adds.add(inttostr(fieldbyname('EditorLeft').asinteger));
    adds.add(inttostr(fieldbyname('EditorHeight').asinteger));
    adds.add(inttostr(fieldbyname('EditorWidth').asinteger));
    adds.add(fieldbyname('EditorFontName').asstring);
    adds.add(inttostr(fieldbyname('EditorFontStyle').asinteger));
    adds.add(inttostr(fieldbyname('EditorFontSize').asinteger));
    work:='FALSE'; if fieldbyname('EditorWrap').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('EditorShowWidthbar').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('EditorAsk').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('EditorClear').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('ImageryTop').asinteger));
    adds.add(inttostr(fieldbyname('ImageryLeft').asinteger));
    work:='FALSE'; if fieldbyname('ImageryShowing').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('cl1').asinteger));
    adds.add(inttostr(fieldbyname('cl2').asinteger));
    adds.add(inttostr(fieldbyname('cl3').asinteger));
    adds.add(inttostr(fieldbyname('cl4').asinteger));
    adds.add(inttostr(fieldbyname('cl5').asinteger));
    adds.add(inttostr(fieldbyname('cm1').asinteger));
    adds.add(inttostr(fieldbyname('cm2').asinteger));
    adds.add(inttostr(fieldbyname('cm3').asinteger));
    adds.add(inttostr(fieldbyname('cm4').asinteger));
    adds.add(inttostr(fieldbyname('cm5').asinteger));
    adds.add(inttostr(fieldbyname('ch1').asinteger));
    adds.add(inttostr(fieldbyname('ch2').asinteger));
    adds.add(inttostr(fieldbyname('ch3').asinteger));
    adds.add(inttostr(fieldbyname('ch4').asinteger));
    adds.add(inttostr(fieldbyname('ch5').asinteger));
    adds.add(inttostr(fieldbyname('c1001').asinteger));
    adds.add(inttostr(fieldbyname('c1002').asinteger));
    adds.add(inttostr(fieldbyname('c1003').asinteger));
    adds.add(inttostr(fieldbyname('c1004').asinteger));
    adds.add(inttostr(fieldbyname('c1005').asinteger));
    adds.add(inttostr(fieldbyname('co1').asinteger));
    adds.add(inttostr(fieldbyname('co2').asinteger));
    adds.add(inttostr(fieldbyname('co3').asinteger));
    adds.add(inttostr(fieldbyname('co4').asinteger));
    adds.add(inttostr(fieldbyname('co5').asinteger));
    adds.add(fieldbyname('Last0').asstring);
    adds.add(fieldbyname('Last1').asstring);
    adds.add(fieldbyname('Last2').asstring);
    adds.add(fieldbyname('Last3').asstring);
    adds.add(fieldbyname('Last4').asstring);
    adds.add(fieldbyname('Last5').asstring);
    adds.add(fieldbyname('Last6').asstring);
    adds.add(fieldbyname('Last7').asstring);
    adds.add(fieldbyname('Last8').asstring);
    adds.add(fieldbyname('Last9').asstring);
    work:='FALSE'; if fieldbyname('NTyped').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('NAutotyper').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('NAliases').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('NMacros').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('NEvents').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('NPasted').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('FToolbarTop').asinteger));
    adds.add(inttostr(fieldbyname('FToolbarLeft').asinteger));
    adds.add(inttostr(fieldbyname('FToolbarHeight').asinteger));
    adds.add(inttostr(fieldbyname('FToolbarWidth').asinteger));
    work:='FALSE'; if fieldbyname('FToolbarVertical').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('FToolbarShowing').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('FToolbarStayOnTop').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('MessagesTop').asinteger));
    adds.add(inttostr(fieldbyname('MessagesLeft').asinteger));
    adds.add(inttostr(fieldbyname('MessagesWidth').asinteger));
    work:='FALSE'; if fieldbyname('MessagesStayOnTop').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('MessagesShowing').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('ChatTop').asinteger));
    adds.add(inttostr(fieldbyname('ChatLeft').asinteger));
    adds.add(inttostr(fieldbyname('ChatHeight').asinteger));
    adds.add(inttostr(fieldbyname('ChatWidth').asinteger));
    work:='FALSE'; if fieldbyname('ChatStayOnTop').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('ChatExpanded').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('ChatShowing').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('ChatLineHeight').asinteger));
    work:='FALSE'; if fieldbyname('ChatShowLineGrid').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('ChatLineGridHeight').asinteger));
    adds.add(inttostr(fieldbyname('ColorScreen').asinteger));
    adds.add(inttostr(fieldbyname('ColorText').asinteger));
    adds.add(inttostr(fieldbyname('Color0').asinteger));
    adds.add(inttostr(fieldbyname('Color1').asinteger));
    adds.add(inttostr(fieldbyname('Color2').asinteger));
    adds.add(inttostr(fieldbyname('Color3').asinteger));
    adds.add(inttostr(fieldbyname('Color4').asinteger));
    adds.add(inttostr(fieldbyname('Color5').asinteger));
    adds.add(inttostr(fieldbyname('Color6').asinteger));
    adds.add(inttostr(fieldbyname('Color7').asinteger));
    adds.add(inttostr(fieldbyname('Color8').asinteger));
    adds.add(inttostr(fieldbyname('Color9').asinteger));
    adds.add(inttostr(fieldbyname('Color10').asinteger));
    adds.add(inttostr(fieldbyname('Color11').asinteger));
    adds.add(inttostr(fieldbyname('Color12').asinteger));
    adds.add(inttostr(fieldbyname('Color13').asinteger));
    adds.add(inttostr(fieldbyname('Color14').asinteger));
    adds.add(inttostr(fieldbyname('Color15').asinteger));
    adds.add(fieldbyname('Anchors').asstring);
    work:='FALSE'; if fieldbyname('AltF4ToClose').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('ReverseKeymap').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('FRetain').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('RetainAll').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('EnableTicker').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(fieldbyname('PanicMacro').asstring);
    work:='FALSE'; if fieldbyname('AddBang').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('FColorSelected').asinteger));
    adds.add(inttostr(fieldbyname('BColorSelected').asinteger));
    work:='FALSE'; if fieldbyname('ParsingChar').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(fieldbyname('Quickchar').asstring);
    adds.add(inttostr(fieldbyname('FColorSystem').asinteger));
    adds.add(inttostr(fieldbyname('BColorSystem').asinteger));
    work:='FALSE'; if fieldbyname('ShowHP3').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('ImageryHeight').asinteger));
    adds.add(inttostr(fieldbyname('ImageryWidth').asinteger));
    adds.add(inttostr(fieldbyname('ImageryColor').asinteger));
    work:='FALSE'; if fieldbyname('ImageryStayOnTop').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('EditorStayOnTop').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('ImageryShowGauge').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('ImageryShowLabel').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('ShowHP4').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('HP3Offset').asinteger));
    adds.add(inttostr(fieldbyname('HP4Offset').asinteger));
    adds.add(fieldbyname('GP1Mask').asstring);
    adds.add(fieldbyname('GP2Mask').asstring);
    adds.add(inttostr(fieldbyname('HP3Size').asinteger));
    adds.add(inttostr(fieldbyname('HP4Size').asinteger));
    work:='FALSE'; if fieldbyname('HighlightKeyhistory').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('DTYped').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('DAutotyper').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('DPasted').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('DAliases').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('DMacros').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('DEvents').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('EQuickchars').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('EScheduler').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('ETicker').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('EParsed').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('NQuickchars').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('NScheduler').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('NTicker').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('NParsed').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('DQuickchars').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('DScheduler').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('DTicker').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('DParsed').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('FColorQuickchars').asinteger));
    adds.add(inttostr(fieldbyname('BColorQuickchars').asinteger));
    adds.add(inttostr(fieldbyname('FColorScheduler').asinteger));
    adds.add(inttostr(fieldbyname('BColorScheduler').asinteger));
    adds.add(inttostr(fieldbyname('FColorTicker').asinteger));
    adds.add(inttostr(fieldbyname('BColorTicker').asinteger));
    adds.add(inttostr(fieldbyname('FColorParsed').asinteger));
    adds.add(inttostr(fieldbyname('BColorParsed').asinteger));
    adds.add(inttostr(fieldbyname('FilteredTop').asinteger));
    adds.add(inttostr(fieldbyname('FilteredLeft').asinteger));
    adds.add(inttostr(fieldbyname('FilteredHeight').asinteger));
    adds.add(inttostr(fieldbyname('FilteredWidth').asinteger));
    work:='FALSE'; if fieldbyname('FilteredShowing').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('FilteredStayOnTop').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('EditorFColor').asinteger));
    adds.add(inttostr(fieldbyname('EditorBColor').asinteger));
    work:='FALSE'; if fieldbyname('UseLocalDir').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(fieldbyname('LocalDir').asstring);
    work:='FALSE'; if fieldbyname('OverwriteLocalDir').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(''); //Defunct fieldbyname('MenuHotkeys').asstring
  end;
  //Options2
  with Datawell.TableOptions2 do begin
    work:='FALSE'; if fieldbyname('BTyped').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('BAutotyped').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('BPasted').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('BAliases').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('BMacros').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('BEvents').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('BQuickchars').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('BScheduler').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('BTicker').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('BParsed').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('Truncate').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('VarTop').asinteger));
    adds.add(inttostr(fieldbyname('VarLeft').asinteger));
    adds.add(inttostr(fieldbyname('VarHeight').asinteger));
    work:='FALSE'; if fieldbyname('VarShowing').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('VarStayOnTop').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('VTyped').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('VAutotyped').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('VPasted').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('VAliases').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('VMacros').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('VEvents').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('VQuickchars').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('VScheduler').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('VTicker').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('VParsed').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(fieldbyname('Groups').asstring);
    work:='FALSE'; if fieldbyname('AutoShowImagery').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('EnableHyperlinks').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('HyperlinkFGColor').asinteger));
    adds.add(inttostr(fieldbyname('HyperlinkBGColor').asinteger));
    adds.add(fieldbyname('Browser').asstring);
    work:='FALSE'; if fieldbyname('FTyped').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('FAutotyped').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('FPasted').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('FAliases').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('FMacros').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('FEvents').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('FQuickchars').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('FScheduler').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('FTicker').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('FParsed').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('PTyped').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('PAutotyped').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('PPasted').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('PAliases').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('PMacros').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('PEvents').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('PQuickchars').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('PScheduler').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('PTicker').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('PParsed').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('MapShowing').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('MapTop').asinteger));
    adds.add(inttostr(fieldbyname('MapLeft').asinteger));
    work:='FALSE'; if fieldbyname('MapStayOnTop').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('DisableAliasLED').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('AutoExpand').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('WebsitesShowing').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('WebsitesStayOnTop').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('WebsitesTop').asinteger));
    adds.add(inttostr(fieldbyname('WebsitesLeft').asinteger));
    work:='FALSE'; if fieldbyname('DataShowing').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('DataStayOnTop').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(inttostr(fieldbyname('DataTop').asinteger));
    adds.add(inttostr(fieldbyname('DataLeft').asinteger));
    adds.add(inttostr(fieldbyname('PastedDelay').asinteger));
    work:='FALSE'; if fieldbyname('FullFlash').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(fieldbyname('HPMask').asstring);
    adds.add(fieldbyname('SPMask').asstring);
    work:='FALSE'; if fieldbyname('DelayUpload').asboolean then work:='TRUE';
      adds.add(work);
    work:='FALSE'; if fieldbyname('PCorrect').asboolean then work:='TRUE';
      adds.add(work);
    adds.add(fieldbyname('PanicMacro2').asstring);
  end;
  //Options3
  with Datawell.TableOptions3 do begin
    adds.add(fieldbyname('S1').asstring);
    adds.add(fieldbyname('S2').asstring);
    adds.add(fieldbyname('S3').asstring);
    adds.add(fieldbyname('S4').asstring);
    adds.add(fieldbyname('S5').asstring);
    adds.add(fieldbyname('S6').asstring);
    adds.add(fieldbyname('S7').asstring);
    adds.add(fieldbyname('S8').asstring);
    adds.add(fieldbyname('S9').asstring);
    adds.add(fieldbyname('S10').asstring);
    adds.add(fieldbyname('S11').asstring);
    adds.add(fieldbyname('S12').asstring);
    adds.add(fieldbyname('S13').asstring);
    adds.add(fieldbyname('S14').asstring);
    adds.add(fieldbyname('S15').asstring);
    adds.add(fieldbyname('S16').asstring);
    adds.add(fieldbyname('S17').asstring);
    adds.add(fieldbyname('S18').asstring);
    adds.add(fieldbyname('S19').asstring);
    adds.add(fieldbyname('S20').asstring);
    adds.add(fieldbyname('S21').asstring);
    adds.add(fieldbyname('S22').asstring);
    adds.add(fieldbyname('S23').asstring);
    adds.add(fieldbyname('S24').asstring);
    adds.add(fieldbyname('S25').asstring);
    adds.add(fieldbyname('S26').asstring);
    adds.add(fieldbyname('S27').asstring);
    adds.add(fieldbyname('S28').asstring);
    adds.add(fieldbyname('S29').asstring);
    adds.add(fieldbyname('S30').asstring);
    adds.add(fieldbyname('S31').asstring);
    adds.add(fieldbyname('S32').asstring);
    adds.add(fieldbyname('S33').asstring);
    adds.add(fieldbyname('S34').asstring);
    adds.add(fieldbyname('S35').asstring);
    adds.add(fieldbyname('S36').asstring);
    adds.add(fieldbyname('S37').asstring);
    adds.add(fieldbyname('S38').asstring);
    adds.add(fieldbyname('S39').asstring);
    adds.add(fieldbyname('S40').asstring);
    adds.add(fieldbyname('S41').asstring);
    adds.add(fieldbyname('S42').asstring);
    adds.add(fieldbyname('S43').asstring);
    adds.add(fieldbyname('S44').asstring);
    adds.add(fieldbyname('S45').asstring);
    adds.add(fieldbyname('S46').asstring);
    adds.add(fieldbyname('S47').asstring);
    adds.add(fieldbyname('S48').asstring);
    adds.add(fieldbyname('S49').asstring);
    adds.add(fieldbyname('S50').asstring);
    adds.add(fieldbyname('S51').asstring);
    adds.add(fieldbyname('S52').asstring);
    adds.add(fieldbyname('S53').asstring);
    adds.add(fieldbyname('S54').asstring);
    adds.add(fieldbyname('S55').asstring);
    adds.add(fieldbyname('S56').asstring);
    adds.add(fieldbyname('S57').asstring);
    adds.add(fieldbyname('S58').asstring);
    adds.add(fieldbyname('S59').asstring);
    adds.add(fieldbyname('S60').asstring);
    adds.add(fieldbyname('S61').asstring);
    adds.add(fieldbyname('S62').asstring);
    adds.add(fieldbyname('S63').asstring);
    adds.add(fieldbyname('S64').asstring);
    adds.add(fieldbyname('S65').asstring);
    adds.add(fieldbyname('S66').asstring);
    adds.add(fieldbyname('S67').asstring);
    adds.add(fieldbyname('S68').asstring);
    adds.add(fieldbyname('S69').asstring);
    adds.add(fieldbyname('S70').asstring);
    adds.add(fieldbyname('S71').asstring);
    adds.add(fieldbyname('S72').asstring);
    adds.add(fieldbyname('S73').asstring);
    adds.add(fieldbyname('S74').asstring);
    adds.add(fieldbyname('S75').asstring);
    adds.add(inttostr(fieldbyname('I1').asinteger));
    adds.add(inttostr(fieldbyname('I2').asinteger));
    adds.add(inttostr(fieldbyname('I3').asinteger));
    adds.add(inttostr(fieldbyname('I4').asinteger));
    adds.add(inttostr(fieldbyname('I5').asinteger));
    adds.add(inttostr(fieldbyname('I6').asinteger));
    adds.add(inttostr(fieldbyname('I7').asinteger));
    adds.add(inttostr(fieldbyname('I8').asinteger));
    adds.add(inttostr(fieldbyname('I9').asinteger));
    adds.add(inttostr(fieldbyname('I10').asinteger));
    adds.add(inttostr(fieldbyname('I11').asinteger));
    adds.add(inttostr(fieldbyname('I12').asinteger));
    adds.add(inttostr(fieldbyname('I13').asinteger));
    adds.add(inttostr(fieldbyname('I14').asinteger));
    adds.add(inttostr(fieldbyname('I15').asinteger));
    adds.add(inttostr(fieldbyname('I16').asinteger));
    adds.add(inttostr(fieldbyname('I17').asinteger));
    adds.add(inttostr(fieldbyname('I18').asinteger));
    adds.add(inttostr(fieldbyname('I19').asinteger));
    adds.add(inttostr(fieldbyname('I20').asinteger));
    adds.add(inttostr(fieldbyname('I21').asinteger));
    adds.add(inttostr(fieldbyname('I22').asinteger));
    adds.add(inttostr(fieldbyname('I23').asinteger));
    adds.add(inttostr(fieldbyname('I24').asinteger));
    adds.add(inttostr(fieldbyname('I25').asinteger));
    adds.add(inttostr(fieldbyname('I26').asinteger));
    adds.add(inttostr(fieldbyname('I27').asinteger));
    adds.add(inttostr(fieldbyname('I28').asinteger));
    adds.add(inttostr(fieldbyname('I29').asinteger));
    adds.add(inttostr(fieldbyname('I30').asinteger));
    adds.add(inttostr(fieldbyname('I31').asinteger));
    adds.add(inttostr(fieldbyname('I32').asinteger));
    adds.add(inttostr(fieldbyname('I33').asinteger));
    adds.add(inttostr(fieldbyname('I34').asinteger));
    adds.add(inttostr(fieldbyname('I35').asinteger));
    adds.add(inttostr(fieldbyname('I36').asinteger));
    adds.add(inttostr(fieldbyname('I37').asinteger));
    adds.add(inttostr(fieldbyname('I38').asinteger));
    adds.add(inttostr(fieldbyname('I39').asinteger));
    adds.add(inttostr(fieldbyname('I40').asinteger));
    adds.add(inttostr(fieldbyname('I41').asinteger));
    adds.add(inttostr(fieldbyname('I42').asinteger));
    adds.add(inttostr(fieldbyname('I43').asinteger));
    adds.add(inttostr(fieldbyname('I44').asinteger));
    adds.add(inttostr(fieldbyname('I45').asinteger));
    adds.add(inttostr(fieldbyname('I46').asinteger));
    adds.add(inttostr(fieldbyname('I47').asinteger));
    adds.add(inttostr(fieldbyname('I48').asinteger));
    adds.add(inttostr(fieldbyname('I49').asinteger));
    adds.add(inttostr(fieldbyname('I50').asinteger));
    adds.add(inttostr(fieldbyname('I51').asinteger));
    adds.add(inttostr(fieldbyname('I52').asinteger));
    adds.add(inttostr(fieldbyname('I53').asinteger));
    adds.add(inttostr(fieldbyname('I54').asinteger));
    adds.add(inttostr(fieldbyname('I55').asinteger));
    adds.add(inttostr(fieldbyname('I56').asinteger));
    adds.add(inttostr(fieldbyname('I57').asinteger));
    adds.add(inttostr(fieldbyname('I58').asinteger));
    adds.add(inttostr(fieldbyname('I59').asinteger));
    adds.add(inttostr(fieldbyname('I60').asinteger));
    adds.add(inttostr(fieldbyname('I61').asinteger));
    adds.add(inttostr(fieldbyname('I62').asinteger));
    adds.add(inttostr(fieldbyname('I63').asinteger));
    adds.add(inttostr(fieldbyname('I64').asinteger));
    adds.add(inttostr(fieldbyname('I65').asinteger));
    adds.add(inttostr(fieldbyname('I66').asinteger));
    adds.add(inttostr(fieldbyname('I67').asinteger));
    adds.add(inttostr(fieldbyname('I68').asinteger));
    adds.add(inttostr(fieldbyname('I69').asinteger));
    adds.add(inttostr(fieldbyname('I70').asinteger));
    adds.add(inttostr(fieldbyname('I71').asinteger));
    adds.add(inttostr(fieldbyname('I72').asinteger));
    adds.add(inttostr(fieldbyname('I73').asinteger));
    adds.add(inttostr(fieldbyname('I74').asinteger));
    adds.add(inttostr(fieldbyname('I75').asinteger));
    work:='FALSE'; if fieldbyname('L1').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L2').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L3').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L4').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L5').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L6').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L7').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L8').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L9').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L10').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L11').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L12').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L13').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L14').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L15').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L16').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L17').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L18').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L19').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L20').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L21').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L22').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L23').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L24').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L25').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L26').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L27').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L28').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L29').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L30').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L31').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L32').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L33').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L34').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L35').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L36').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L37').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L38').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L39').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L40').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L41').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L42').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L43').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L44').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L45').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L46').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L47').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L48').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L49').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L50').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L51').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L52').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L53').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L54').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L55').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L56').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L57').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L58').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L59').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L60').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L61').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L62').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L63').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L64').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L65').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L66').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L67').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L68').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L69').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L70').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L71').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L72').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L73').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L74').asboolean then work:='TRUE'; adds.add(work);
    work:='FALSE'; if fieldbyname('L75').asboolean then work:='TRUE'; adds.add(work);
    adds.add(fieldbyname('Tool1').asstring);
    adds.add(fieldbyname('Tool2').asstring);
    adds.add(fieldbyname('Tool3').asstring);
    adds.add(fieldbyname('Tool4').asstring);
    adds.add(fieldbyname('Tool5').asstring);
    adds.add(fieldbyname('Tool6').asstring);
    adds.add(fieldbyname('Tool7').asstring);
    adds.add(fieldbyname('Tool8').asstring);
    adds.add(fieldbyname('Tool9').asstring);
    adds.add(fieldbyname('Tool10').asstring);
    adds.add(fieldbyname('Tool11').asstring);
    adds.add(fieldbyname('Tool12').asstring);
  end;
  //Options4
  with Datawell.TableOptions4 do begin
    adds.add(fieldbyname('S1').asstring);
    adds.add(fieldbyname('S2').asstring);
    adds.add(fieldbyname('S3').asstring);
    adds.add(fieldbyname('S4').asstring);
    adds.add(fieldbyname('S5').asstring);
    adds.add(fieldbyname('S6').asstring);
    adds.add(fieldbyname('S7').asstring);
    adds.add(fieldbyname('S8').asstring);
    adds.add(fieldbyname('S9').asstring);
    adds.add(fieldbyname('S10').asstring);
    adds.add(fieldbyname('S11').asstring);
    adds.add(fieldbyname('S12').asstring);
    adds.add(fieldbyname('S13').asstring);
    adds.add(fieldbyname('S14').asstring);
    adds.add(fieldbyname('S15').asstring);
    adds.add(fieldbyname('S16').asstring);
    adds.add(fieldbyname('S17').asstring);
    adds.add(fieldbyname('S18').asstring);
    adds.add(fieldbyname('S19').asstring);
    adds.add(fieldbyname('S20').asstring);
    adds.add(fieldbyname('S21').asstring);
    adds.add(fieldbyname('S22').asstring);
    adds.add(fieldbyname('S23').asstring);
    adds.add(fieldbyname('S24').asstring);
    adds.add(fieldbyname('S25').asstring);
    adds.add(fieldbyname('S26').asstring);
    adds.add(fieldbyname('S27').asstring);
    adds.add(fieldbyname('S28').asstring);
    adds.add(fieldbyname('S29').asstring);
    adds.add(fieldbyname('S30').asstring);
    adds.add(fieldbyname('S31').asstring);
    adds.add(fieldbyname('S32').asstring);
    adds.add(fieldbyname('S33').asstring);
    adds.add(fieldbyname('S34').asstring);
    adds.add(fieldbyname('S35').asstring);
    adds.add(fieldbyname('S36').asstring);
    adds.add(fieldbyname('S37').asstring);
    adds.add(fieldbyname('S38').asstring);
    adds.add(fieldbyname('S39').asstring);
    adds.add(fieldbyname('S40').asstring);
  end;
//Done adding
  Gauge.maxvalue:=adds.count-1;
  AssignFile(TKPFile,DialogSave.filename);
  Rewrite(TKPFile);
  for i:=0 to adds.count-1 do begin
    WriteLn(TKPFile,adds[i]);
    Gauge.progress:=i;
  end;
  CloseFile(TKPFile);
  adds.free;
  coms.free;
  LabelStatus.caption:='Export successful!';
  LabelStatus.font.color:=clgreen;
  BtnOk.enabled:=true;
end;

procedure TFormProfiles.BtnOKClick(Sender: TObject);
begin
  PanelStatus.hide;
  PanelMain.enabled:=true;
  GridProfiles.setfocus;
end;

end.

